package com.example.asus.a522;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class SeccondActivity extends AppCompatActivity {

    @Override
    public void onBackPressed(){
        Intent intent = new Intent();
        intent.putExtra("data_return","Hello FirstActivity");
        setResult(RESULT_OK,intent);
        finish();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_seccond);

        Button btn2 = (Button) findViewById(R.id.button_2);
        btn2.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v){
                //Intent intent = new Intent();
               // intent.putExtra("data_return","Hello FirstActivity");
               // setResult(RESULT_OK,intent);
               // finish();
                Intent intent1 = new Intent(SeccondActivity.this,FirstActivity.class);
                startActivity(intent1);

            }

        });



       // Intent intent = getIntent();
      //  String data = intent.getStringExtra("extra_data");
      //  Log.d("SecondActivity",data);
    }
    @Override
    protected void onDestroy()
    {
        super.onDestroy();
        Log.d("SecondActivity","onDestroy");
    }
}
